package data_stracture.String;

public class 比较 {
    private static  String getXx(){
        return "AB";
    }
    //面试——String类型的多种创建方式和内存地址的比较"
    public static void main(String[] args) {
        String s1 = "ABCD";
        String s2 = "A" + "B" + "C" + "D";
        String s3 = "AB" + "CD";
        String s4 = new String("ABCD");
        String temp = "AB";
        String s5 = temp + "CD";
        String s6 = getXx() + "CD";
        System.out.println(s1 == s2);//true
        System.out.println(s2 == s3);//true
        System.out.println(s3 == s4);//false
        System.out.println(s4 == s5);//false
        System.out.println(s5 == s6);//false
    }
}
